import os
import uuid
from datetime import datetime
from loguru import logger

def initialize_task(agent, command: str, current_situation: dict) -> tuple[str, str, str, dict]:
    project_name = datetime.now().strftime("%Y%m%d")
    task_name = str(uuid.uuid4())
    agent.task_states[task_name] = {
        "status": "running",
        "progress": 0,
        "command": command,
        "start_time": datetime.now().isoformat(),
        "result": "",
        "error": ""
    }
    agent.task_manager_instance.set_current_task(project_name, task_name)
    logger.info(f"Task started: {task_name}")

    return command, project_name, task_name, None
